package com.logistic.common.taglib;

import java.io.IOException;
import java.util.ArrayList;
import java.util.List;

import javax.servlet.jsp.JspWriter;
import javax.servlet.jsp.tagext.TagSupport;

import com.logistic.common.Constants;

public class ShowUpsAndWeight extends TagSupport{ 
	/**
	 * 
	 */
	private static final long serialVersionUID = 6290388793965694092L;
	private String upsWeightStr;




	public int doStartTag() { 
	  JspWriter out = pageContext.getOut();
	  String outPut = "";
	  if("".equals(upsWeightStr) || null == upsWeightStr) return EVAL_PAGE;
	  String [] allUpsAndWeight = upsWeightStr.split(";");
	  List<String> ups = new  ArrayList<String>();
	  List<String> enterWeights = new  ArrayList<String>();
	  for(int i=0;i<allUpsAndWeight.length;i++){
			if(i%2==0){
				ups.add(allUpsAndWeight[i]);
			}else{
				enterWeights.add(allUpsAndWeight[i]);
			}
		}
	  for(int j=0; j<ups.size();j++){
		  //outPut = outPut+"UPS号:"+ups.get(j)+" 重量:"+enterWeights.get(j) +" LBS; ";
		  outPut = outPut+"美国国内运单号:"+ups.get(j)+" 重量:"+enterWeights.get(j) +" LBS; ";
	  }
	  
	  try {
		out.println(outPut);
	} catch (IOException e) {
		e.printStackTrace();
	} 

		
	  return EVAL_PAGE;// 标签执行完后，继续执行后面的 
	}

	public int doEndTag() { 
		  return EVAL_PAGE; 
	} 

	public String getUpsWeightStr() {
		return upsWeightStr;
	}

	public void setUpsWeightStr(String upsWeightStr) {
		this.upsWeightStr = upsWeightStr;
	}
	
}
